﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class WebLawadd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strName, strContent;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            strName =SysFun.ToTrim( Request.Form["txtName"]);
            strContent = SysFun.ToTrim(Request.Form["txtContentHtml"]);

            if (strName!="" && strContent!="")
            {
                if (strName.Trim().Length == 0)
                {
                    Response.Write("<script>alert('标题不能为空！！！');</script>");
                    return;
                }
                if (strContent.Trim().Length == 0)
                {
                    Response.Write("<script>alert('内容不能为空！！！');</script>");
                    return;
                }
                Db db = new Db();
                Grove.ORM.ObjectOperator oo = db.GetObjectOperator();

                HZ.MBSM.Model.law law = new HZ.MBSM.Model.law();
                law.Title = strName;
                law.Content = strContent.Replace("\r\n", "");
                law.ConferDate = Convert.ToDateTime(txtConferdate.Text);
                law.IsDisplay = Convert.ToBoolean(chkIsDisplay.Checked);
                law.AddDate = System.DateTime.Now;
                oo.Insert(law);
                oo.Dispose();
                db.Close();
                Response.Write("<script language=JavaScript>alert('添加成功！！！');</script>");

                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "插入", "law", law.Title + "|" + law.Content + "|" + law.ConferDate + "|" + law.AddDate + "|" + law.IsDisplay, "../Magage/WeblawAdd.aspx");

                Response.Write("<script>window.opener.location.reload();window.close();</script>");

            }
        }

    }
    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
    //    _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
    //    _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
    //    if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
    //    {
    //        Db db = new Db();
    //        Grove.ORM.ObjectOperator oo = db.GetObjectOperator();

    //        HZ.MBSM.Model.law law = new HZ.MBSM.Model.law();
    //        law.Title = txtTitle.Text;
    //        law.Content = txtContent.Text;
    //        law.ConferDate = Convert.ToDateTime(txtConferdate.Text );
    //        law.IsDisplay = Convert.ToBoolean(chkIsDisplay.Checked);
    //        law.AddDate = System.DateTime.Now;
    //        oo.Insert(law);
    //        oo.Dispose();
    //        Response.Write("<script language=JavaScript>alert('添加成功！！！');</script>");
    //        Response.Write("<script>window.opener.location.reload();window.close();</script>");
    //    }
    //}

}
